package top.buaarobot.webserver.repository;

import top.buaarobot.webserver.domain.SystemNotice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface SystemNoticeRepository extends JpaRepository<SystemNotice, Integer> {
    @Query(value = "select * from system_notice where user_id = ?1 order by time desc", nativeQuery = true)
    public Iterable<SystemNotice> searchByUserId(int userId);

    @Transactional
    public void deleteAllByUserId(int userId);
}
